/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aiaudio.processing.prediction.top;

import aiaudio.processing.base.mapreduce.CoordinateDoubleValueKey;
import aiaudio.database.tables.RatingsListTable;
import java.io.IOException;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;

/**
 *
 * @author nastya
 */
public class CollectUserRatingsMapper extends TableMapper<ImmutableBytesWritable, CoordinateDoubleValueKey>{
    
    @Override
    protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {
        byte[] artist = RatingsListTable.getArtistAsBytes(value);
        byte[] user = RatingsListTable.getUserAsBytes(value);
        double rating = RatingsListTable.getCalculatedRating(value);
        context.write(new ImmutableBytesWritable(user), new CoordinateDoubleValueKey(rating, artist));
    }

    
    
}
